package vampirism.core.shared;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Validator {

    public static boolean isValidEmail(String givenEmail) {
    	if(givenEmail == null)return false;
    	if(givenEmail.length() < 3)return false;
    	if(givenEmail.length() > 50)return false;
    	final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"+"[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
    	Pattern pattern = Pattern.compile(EMAIL_PATTERN);
		Matcher matcher = pattern.matcher(givenEmail);
		return matcher.matches();
    }
    
    public static boolean isValidPass(String givenPassword){
    	if(givenPassword == null)return false;
    	if(givenPassword.length() < 3)return false;
    	if(givenPassword.length() > 50)return false;
    	return true;
    }
    
    public static boolean isValidPlayerName(String givenName){
    	if(givenName == null)return false;
    	if(givenName.length() < 3)return false;
    	if(givenName.length() > 12)return false;
    	return givenName.matches("[A-Za-z0-9]+");//only a-z, A-Z, 0-9 symbols allowed
    }
    
    public static boolean isValidPlayerType(int givenType){
    	if(givenType < 0)return false;
    	if(givenType > 5)return false;
    	return true;
    }

	public static boolean isValidPlayerAmount(int currentCharAmount) {
		
		if(currentCharAmount < 5)return true;
		return false;
	}
}
